clear;
N=128;
n=0:N-1;
xn=(0.54-0.46*cos(2*pi*n/(N-1)));
XK=fft(xn,N);
%求幅度谱
magXK=abs(XK);
%求相位谱
phXK=angle(XK);

%画时域信号
stem(n,xn);
xlabel('n');
ylabel('x(n)');
title('x(n) N=128');
%画频谱
[H,W]=freqz(xn,1,512);
plot(W/pi, 20*log10(abs(H)/abs(H(1))));
